﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<link href="js-console.css" rel="stylesheet" />
	<!-- 5. Write script that asks for a digit and depending
			on the input shows the name of that digit (in English)
			using a switch statement. -->
</head>
<body>
	<div id="js-console"></div>
	<script src="js-console.js"></script>
	<script>
		var number = prompt("Enter a digit from 0 to 9 inclusive");
		number *= 1;	// make it real number

		if (!isNaN(number) && number >= 0 && number <= 9) {
			var result = "default";
			switch (number) {
				case 0:
					result = "zero";
					break;
				case 1:
					result = "one";
					break;
				case 2:
					result = "two";
					break;
				case 3:
					result = "three";
					break;
				case 4:
					result = "four";
					break;
				case 5:
					result = "five";
					break;
				case 6:
					result = "six";
					break;
				case 7:
					result = "seven";
					break;
				case 8:
					result = "eight";
					break;
				case 9:
					result = "nine";
					break;
			}

			jsConsole.writeLine(result);
		}
		else {
			jsConsole.writeLine("Wrong input.");
		}
	</script>
</body>
</html>
